//
//  DKPanCardMenberView.m
//  DanKU
//
//  Created by 吴斌 on 2023/11/5.
//

#import "DKPanCardMenberView.h"
@interface DKPanCardMenberView()<UITextFieldDelegate>
@property (nonatomic, strong)UITextField * panCardNameField;
@property (nonatomic, strong)UITextField * panCardNoField;
@end
@implementation DKPanCardMenberView
-(instancetype)init{
    if(self == [super init]){
        self.layer.cornerRadius = DK_IsWidthScale(14);
        self.layer.borderColor = DK_Hex(@"#4566FF").CGColor;
        self.layer.borderWidth = 0.5;
        [self dk_addSubView];
    }
    return self;
}
- (void)dk_addSubView{
    UILabel * dk_AuthCardNameLab = [[UILabel alloc] init];
    dk_AuthCardNameLab.textColor = DK_Hex(@"#333333");
    dk_AuthCardNameLab.text = @"Name：";
    dk_AuthCardNameLab.font = DK_FONT_Regular(15);
    [self addSubview:dk_AuthCardNameLab];
    [dk_AuthCardNameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(DK_IsWidthScale(20)));
        make.top.equalTo(@(DK_IsWidthScale(18)));
        make.height.equalTo(@(DK_IsWidthScale(21)));
    }];
    self.panCardNameField = [[UITextField alloc] init];
    self.panCardNameField.textColor = DK_Hex(@"#333333");
    self.panCardNameField.font = DK_FONT_Medium(15);
    self.panCardNameField.placeholder = @"Please entry";
    self.panCardNameField.textAlignment = NSTextAlignmentRight;
    [self.panCardNameField addTarget:self action:@selector(fieldEditChange) forControlEvents:UIControlEventEditingChanged];
    [self addSubview:self.panCardNameField];
    [self.panCardNameField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(dk_AuthCardNameLab.mas_right);
        make.right.equalTo(@(-DK_IsWidthScale(20)));
        make.top.equalTo(@(DK_IsWidthScale(18)));
        make.height.equalTo(@(DK_IsWidthScale(21)));
    }];
    UIView *panCardLineView = [[UIView alloc] init];
    panCardLineView.backgroundColor = DK_Hex(@"#ECECEC");
    [self addSubview:panCardLineView];
    [panCardLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(DK_IsWidthScale(20)));
        make.right.equalTo(@(-DK_IsWidthScale(20)));
        make.top.equalTo(@(DK_IsWidthScale(50)));
        make.height.equalTo(@(DK_IsWidthScale(1)));
    }];
    
    UILabel * dk_AuthCardNoLab = [[UILabel alloc] init];
    dk_AuthCardNoLab.textColor = DK_Hex(@"#333333");
    dk_AuthCardNoLab.text = @"PAN  NO：";
    dk_AuthCardNoLab.font = DK_FONT_Regular(15);
    [self addSubview:dk_AuthCardNoLab];
    [dk_AuthCardNoLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(DK_IsWidthScale(20)));
        make.top.equalTo(panCardLineView.mas_bottom).offset(DK_IsWidthScale(18));
        make.height.equalTo(@(DK_IsWidthScale(21)));
    }];
    self.panCardNoField = [[UITextField alloc] init];
    self.panCardNoField.textColor = DK_Hex(@"#333333");
    self.panCardNoField.font = DK_FONT_Medium(15);
    self.panCardNoField.placeholder = @"Please entry";
    self.panCardNoField.textAlignment = NSTextAlignmentRight;
    [self.panCardNoField addTarget:self action:@selector(fieldEditChange) forControlEvents:UIControlEventEditingChanged];
    [self addSubview:self.panCardNoField];
    [self.panCardNoField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(dk_AuthCardNoLab.mas_right);
        make.right.equalTo(@(-DK_IsWidthScale(20)));
        make.top.equalTo(dk_AuthCardNoLab);
        make.height.equalTo(@(DK_IsWidthScale(21)));
    }];
}
-(void)setDk_AuthPanCardMdl:(DKAuthPanCardModel *)dk_AuthPanCardMdl{
    _dk_AuthPanCardMdl = dk_AuthPanCardMdl;
    if(_dk_AuthPanCardMdl){
        self.panCardNameField.text = _dk_AuthPanCardMdl.idCardOcrDetails.name;
        self.panCardNoField.text = _dk_AuthPanCardMdl.idCardOcrDetails.idNumber;
    }
}
- (NSString *)getPanCardName{
    return self.panCardNameField.text;
}
- (NSString *)getPanCardNo{
    return self.panCardNoField.text;
}
- (void)fieldEditChange{
    if(self.goCheckPanCardMenberBlock){
        self.goCheckPanCardMenberBlock();
    }
}
//#pragma mark UITextFieldDelegate
//- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
//    NSString * dk_PanCardMenberText = [textField.text stringByReplacingCharactersInRange:range withString:string];
//    if(dk_PanCardMenberText.length > 0){
//        if(self.goCheckPanCardMenberBlock){
//            self.goCheckPanCardMenberBlock(false);
//        }
//    }else{
//        if(self.goCheckPanCardMenberBlock){
//            self.goCheckPanCardMenberBlock(true);
//        }
//    }
//    return YES;
//}
@end
